﻿using System;

using Microsoft.VisualStudio.TemplateWizard;

namespace CamoteqItemWizard
{
    public class ScaffoldingWizard : IWizard
    {
        private bool saveAction = false;

        public void RunStarted(object automationObject, System.Collections.Generic.Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            string solutionDirectory;
            if (!replacementsDictionary.TryGetValue("$solutiondirectory$", out solutionDirectory) == true)
            {
                throw new Exception("Invalid soultion directory");
            }

            string projectNamespace;
            if (!replacementsDictionary.TryGetValue("$rootnamespace$", out projectNamespace) == true)
            {
                throw new Exception("Invalid soultion name");
            }

            var rootNamespace = projectNamespace.Replace(".App", string.Empty);
            var form = new MainForm(solutionDirectory, rootNamespace);
            var result = form.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                this.saveAction = true;
            }
        }

        public bool ShouldAddProjectItem(string filePath)
        {
            // TODO
            // return this.saveAction;

            return false;
        }

        public void BeforeOpeningFile(EnvDTE.ProjectItem projectItem)
        {
        }

        public void ProjectFinishedGenerating(EnvDTE.Project project)
        {
        }

        public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem)
        {
        }

        public void RunFinished()
        {
        }              
    }
}
